package cn.cvs.service.supplier;

import cn.cvs.mapper.supplier.SupplierMapper;
import cn.cvs.pojo.Supplier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.ServletContext;
import java.util.List;

@Transactional
@Service
public class SupplierServiceImpl implements SupplierService{

    @Autowired
    private SupplierMapper supplierMapper;

    @Override
    public int add(Supplier var1) throws Exception {
        return supplierMapper.add(var1);
    }

    @Override
    public List<Supplier> selectList(String var1, String var2, Integer var3, Integer var4) throws Exception {
        var3 = (var3 - 1) * var4;
        return supplierMapper.selectList(var1, var2, var3, var4);
    }

    @Override
    public int selectCount(String var1, String var2) throws Exception {
        return supplierMapper.selectCount(var1, var2);
    }

    @Override
    public int deleteById(Integer var1, ServletContext context) {
        int result = 0;
        boolean flag = true;
        try {
            result = supplierMapper.deleteById(var1);
        }catch (Exception e){
            e.printStackTrace();
            throw new RuntimeException();
        }
        return result;
    }

    @Override
    public Supplier selectById(Integer var1) throws Exception {
        return supplierMapper.selectById(var1);
    }

    @Override
    public int update(Supplier var1) throws Exception {
        return supplierMapper.update(var1);
    }
}
